package Day23;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int t = in.nextInt();
            for(int i = 0; i < t; i++){
                int h = in.nextInt();
                int a = in.nextInt();
                int H = in.nextInt();
                int A = in.nextInt();
                int attackCount = 0;
                if(h % A != 0){
                    attackCount = h / A + 1;
                }else{
                    attackCount = h / A;
                }
                int attackSum = attackCount * a;
                int count = attackSum / H;
                System.out.print(count);
            }

        }
    }
}
